<?php
/**
 * Created by PhpStorm.
 * User: wei
 * Date: 2016/6/1
 * Time: 15:08
 */
namespace Admin\Controller;
use Think\Controller;

class InterestRateController extends CommonController
{
    protected function _initialize()
    {
        parent::_initialize();
        $this->breadcrumb1 = '基础数据管理';
        $this->breadcrumb2 = '维修保证金利率管理';
        $this->url = U('InterestRate/index');
    }

    public function index(){
        $menu_id=$_GET['id'];
        $jur=jur_str($menu_id,$this->user_id);
        $count=M('interestrate')->where('is_delete=0')->count();
        $Page       = new \Think\Page($count,25);
        $show       = $Page->show();
        $list=M('interestrate')->where('is_delete=0')->limit($Page->firstRow.','.$Page->listRows)->select();

        $this->assign('list',$list);
        $this->assign('page',$show);
        $this->assign('update',$jur['is_update']);// 赋值数据集
        $this->assign('delete',$jur['is_delete']);// 赋值数据集
        $this->display();
    }

    //更改
    public function change(){
        $id=I('post.id');
        $status=I('post.status');
        $data['status']=$status;
        M('interestrate')->where("id=$id")->save($data);
        exit;
    }

    //跳转页面
    public function update(){
        $id=I('get.id'.'','int');
        $where['id']=$id;
        $detail=M('interestrate')->where($where)->find();
        $this->assign('detail',$detail);
        $this->display();
    }

    //删除
    public function delete(){
        $id=I('post.id');

        $data['is_delete']=1;
        M('interestrate')->where("id=$id")->save($data);
        echo 1;
        exit;
    }
}